<!DOCTYPE html><html lang="zh-CN" data-theme="light"><head><meta charset="UTF-8"><meta http-equiv="X-UA-Compatible" content="IE=edge"><meta name="viewport" content="width=device-width, initial-scale=1.0, maximum-scale=1.0"><title>Docker安装 | 卖萌的西瓜拐了夏天当媳妇</title><meta name="author" content="凯雄"><meta name="copyright" content="凯雄"><meta name="format-detection" content="telephone=no"><meta name="theme-color" content="#ffffff"><meta name="description" content="安装containerd上传文件后解压缩1tar -xvf cri-containerd-cni-1.6.4-linux-arm64.tar.gz -C &#x2F;  1mkdir &#x2F;etc&#x2F;containerd  1containerd config default &gt; &#x2F;etc&#x2F;containerd&#x2F;config.toml  12systemctl start containerdsystemc">
<meta property="og:type" content="article">
<meta property="og:title" content="Docker安装">
<meta property="og:url" content="https://gitee.com/songkaiixong/songkaixiong.git/2023/03/09/02%E6%89%8B%E5%8A%A8%E9%83%A8%E7%BD%B2k8s/index.html">
<meta property="og:site_name" content="卖萌的西瓜拐了夏天当媳妇">
<meta property="og:description" content="安装containerd上传文件后解压缩1tar -xvf cri-containerd-cni-1.6.4-linux-arm64.tar.gz -C &#x2F;  1mkdir &#x2F;etc&#x2F;containerd  1containerd config default &gt; &#x2F;etc&#x2F;containerd&#x2F;config.toml  12systemctl start containerdsystemc">
<meta property="og:locale" content="zh_CN">
<meta property="og:image" content="https://gitee.com/songkaiixong/songkaixiong.git/img/docker%E5%AE%89%E8%A3%85%E6%AD%A5%E9%AA%A4.jpg">
<meta property="article:published_time" content="2023-03-09T13:34:28.018Z">
<meta property="article:modified_time" content="2023-03-09T13:35:46.712Z">
<meta property="article:author" content="凯雄">
<meta name="twitter:card" content="summary">
<meta name="twitter:image" content="https://gitee.com/songkaiixong/songkaixiong.git/img/docker%E5%AE%89%E8%A3%85%E6%AD%A5%E9%AA%A4.jpg"><link rel="shortcut icon" href="/songkaiixong/songkaixiong.git/img/loge.png"><link rel="canonical" href="https://gitee.com/songkaiixong/songkaixiong.git/2023/03/09/02%E6%89%8B%E5%8A%A8%E9%83%A8%E7%BD%B2k8s/index.html"><link rel="preconnect" href="//cdn.jsdelivr.net"/><link rel="preconnect" href="//busuanzi.ibruce.info"/><link rel="stylesheet" href="/songkaiixong/songkaixiong.git/css/index.css"><link rel="stylesheet" href="https://cdn.jsdelivr.net/npm/@fortawesome/fontawesome-free/css/all.min.css" media="print" onload="this.media='all'"><link rel="stylesheet" href="https://cdn.jsdelivr.net/npm/@fancyapps/ui/dist/fancybox.min.css" media="print" onload="this.media='all'"><script>const GLOBAL_CONFIG = { 
  root: '/songkaiixong/songkaixiong.git/',
  algolia: undefined,
  localSearch: {"path":"/songkaiixong/songkaixiong.git/search.xml","preload":false,"languages":{"hits_empty":"找不到您查询的内容：${query}"}},
  translate: undefined,
  noticeOutdate: undefined,
  highlight: {"plugin":"highlighjs","highlightCopy":true,"highlightLang":true,"highlightHeightLimit":false},
  copy: {
    success: '复制成功',
    error: '复制错误',
    noSupport: '浏览器不支持'
  },
  relativeDate: {
    homepage: true,
    post: true
  },
  runtime: '',
  date_suffix: {
    just: '刚刚',
    min: '分钟前',
    hour: '小时前',
    day: '天前',
    month: '个月前'
  },
  copyright: {"limitCount":50,"languages":{"author":"作者: 凯雄","link":"链接: ","source":"来源: 卖萌的西瓜拐了夏天当媳妇","info":"著作权归作者所有。商业转载请联系作者获得授权，非商业转载请注明出处。"}},
  lightbox: 'fancybox',
  Snackbar: undefined,
  source: {
    justifiedGallery: {
      js: 'https://cdn.jsdelivr.net/npm/flickr-justified-gallery/dist/fjGallery.min.js',
      css: 'https://cdn.jsdelivr.net/npm/flickr-justified-gallery/dist/fjGallery.min.css'
    }
  },
  isPhotoFigcaption: false,
  islazyload: false,
  isAnchor: false,
  percent: {
    toc: true,
    rightside: false,
  }
}</script><script id="config-diff">var GLOBAL_CONFIG_SITE = {
  title: 'Docker安装',
  isPost: true,
  isHome: false,
  isHighlightShrink: false,
  isToc: true,
  postUpdate: '2023-03-09 21:35:46'
}</script><noscript><style type="text/css">
  #nav {
    opacity: 1
  }
  .justified-gallery img {
    opacity: 1
  }

  #recent-posts time,
  #post-meta time {
    display: inline !important
  }
</style></noscript><script>(win=>{
    win.saveToLocal = {
      set: function setWithExpiry(key, value, ttl) {
        if (ttl === 0) return
        const now = new Date()
        const expiryDay = ttl * 86400000
        const item = {
          value: value,
          expiry: now.getTime() + expiryDay,
        }
        localStorage.setItem(key, JSON.stringify(item))
      },

      get: function getWithExpiry(key) {
        const itemStr = localStorage.getItem(key)

        if (!itemStr) {
          return undefined
        }
        const item = JSON.parse(itemStr)
        const now = new Date()

        if (now.getTime() > item.expiry) {
          localStorage.removeItem(key)
          return undefined
        }
        return item.value
      }
    }
  
    win.getScript = url => new Promise((resolve, reject) => {
      const script = document.createElement('script')
      script.src = url
      script.async = true
      script.onerror = reject
      script.onload = script.onreadystatechange = function() {
        const loadState = this.readyState
        if (loadState && loadState !== 'loaded' && loadState !== 'complete') return
        script.onload = script.onreadystatechange = null
        resolve()
      }
      document.head.appendChild(script)
    })
  
    win.getCSS = (url,id = false) => new Promise((resolve, reject) => {
      const link = document.createElement('link')
      link.rel = 'stylesheet'
      link.href = url
      if (id) link.id = id
      link.onerror = reject
      link.onload = link.onreadystatechange = function() {
        const loadState = this.readyState
        if (loadState && loadState !== 'loaded' && loadState !== 'complete') return
        link.onload = link.onreadystatechange = null
        resolve()
      }
      document.head.appendChild(link)
    })
  
      const asideStatus = saveToLocal.get('aside-status')
      if (asideStatus !== undefined) {
        if (asideStatus === 'hide') {
          document.documentElement.classList.add('hide-aside')
        } else {
          document.documentElement.classList.remove('hide-aside')
        }
      }
    
    const detectApple = () => {
      if(/iPad|iPhone|iPod|Macintosh/.test(navigator.userAgent)){
        document.documentElement.classList.add('apple')
      }
    }
    detectApple()
    })(window)</script><link rel="stylesheet" href="/css/custom.css"><link rel="stylesheet" href="/css/custom.css"><link rel="stylesheet" href="/css/readPercent.css"><link rel="stylesheet" href="/css/universe.css"><svg aria-hidden="true" style="position:absolute; overflow:hidden; width:0; height:0"><symbol id="icon-sun" viewBox="0 0 1024 1024"><path d="M960 512l-128 128v192h-192l-128 128-128-128H192v-192l-128-128 128-128V192h192l128-128 128 128h192v192z" fill="#FFD878" p-id="8420"></path><path d="M736 512a224 224 0 1 0-448 0 224 224 0 1 0 448 0z" fill="#FFE4A9" p-id="8421"></path><path d="M512 109.248L626.752 224H800v173.248L914.752 512 800 626.752V800h-173.248L512 914.752 397.248 800H224v-173.248L109.248 512 224 397.248V224h173.248L512 109.248M512 64l-128 128H192v192l-128 128 128 128v192h192l128 128 128-128h192v-192l128-128-128-128V192h-192l-128-128z" fill="#4D5152" p-id="8422"></path><path d="M512 320c105.888 0 192 86.112 192 192s-86.112 192-192 192-192-86.112-192-192 86.112-192 192-192m0-32a224 224 0 1 0 0 448 224 224 0 0 0 0-448z" fill="#4D5152" p-id="8423"></path></symbol><symbol id="icon-moon" viewBox="0 0 1024 1024"><path d="M611.370667 167.082667a445.013333 445.013333 0 0 1-38.4 161.834666 477.824 477.824 0 0 1-244.736 244.394667 445.141333 445.141333 0 0 1-161.109334 38.058667 85.077333 85.077333 0 0 0-65.066666 135.722666A462.08 462.08 0 1 0 747.093333 102.058667a85.077333 85.077333 0 0 0-135.722666 65.024z" fill="#FFB531" p-id="11345"></path><path d="M329.728 274.133333l35.157333-35.157333a21.333333 21.333333 0 1 0-30.165333-30.165333l-35.157333 35.157333-35.114667-35.157333a21.333333 21.333333 0 0 0-30.165333 30.165333l35.114666 35.157333-35.114666 35.157334a21.333333 21.333333 0 1 0 30.165333 30.165333l35.114667-35.157333 35.157333 35.157333a21.333333 21.333333 0 1 0 30.165333-30.165333z" fill="#030835" p-id="11346"></path></symbol></svg><!-- hexo injector head_end start --><link rel="stylesheet" href="https://cdn.jsdelivr.net/gh/Zfour/Butterfly-double-row-display@1.00/cardlistpost.min.css"/>
<style>#recent-posts > .recent-post-item >.recent-post-info > .article-meta-wrap > .tags:before {content:"\A";
  white-space: pre;}#recent-posts > .recent-post-item >.recent-post-info > .article-meta-wrap > .tags > .article-meta__separator{display:none}</style>
<link rel="stylesheet" href="https://npm.elemecdn.com/hexo-butterfly-wowjs/lib/animate.min.css" media="print" onload="this.media='screen'"><link rel="stylesheet" href="https://npm.elemecdn.com/hexo-filter-gitcalendar/lib/gitcalendar.css" media="print" onload="this.media='all'"><!-- hexo injector head_end end --><meta name="generator" content="Hexo 6.3.0"></head><body><div id="web_bg"></div><div id="sidebar"><div id="menu-mask"></div><div id="sidebar-menus"><div class="avatar-img is-center"><img src="/songkaiixong/songkaixiong.git/img/touxiang.png" onerror="onerror=null;src='/img/friend_404.gif'" alt="avatar"/></div><div class="sidebar-site-data site-data is-center"><a href="/songkaiixong/songkaixiong.git/archives/"><div class="headline">文章</div><div class="length-num">2</div></a><a href="/songkaiixong/songkaixiong.git/tags/"><div class="headline">标签</div><div class="length-num">0</div></a><a href="/songkaiixong/songkaixiong.git/categories/"><div class="headline">分类</div><div class="length-num">0</div></a></div><hr/><div class="menus_items"><div class="menus_item"><a class="site-page" href="/songkaiixong/songkaixiong.git/"><i class="fa-fw fas fa-home"></i><span> 首页</span></a></div><div class="menus_item"><a class="site-page" href="/songkaiixong/songkaixiong.git/archives/"><i class="fa-fw fas fa-archive"></i><span> 时间轴</span></a></div><div class="menus_item"><a class="site-page" href="/songkaiixong/songkaixiong.git/tags/"><i class="fa-fw fas fa-tags"></i><span> 标签</span></a></div><div class="menus_item"><a class="site-page" href="/songkaiixong/songkaixiong.git/categories/"><i class="fa-fw fas fa-folder-open"></i><span> 分类</span></a></div><div class="menus_item"><a class="site-page" href="/songkaiixong/songkaixiong.git/link/"><i class="fa-fw fas fa-link"></i><span> 友链</span></a></div><div class="menus_item"><a class="site-page" href="/songkaiixong/songkaixiong.git/about/"><i class="fa-fw fas fa-heart"></i><span> 关于</span></a></div></div></div></div><div class="post" id="body-wrap"><header class="post-bg" id="page-header" style="background-image: url('/songkaiixong/songkaixiong.git/img/docker%E5%AE%89%E8%A3%85%E6%AD%A5%E9%AA%A4.jpg')"><nav id="nav"><span id="blog-info"><a href="/songkaiixong/songkaixiong.git/" title="卖萌的西瓜拐了夏天当媳妇"><span class="site-name">卖萌的西瓜拐了夏天当媳妇</span></a></span><div id="menus"><div id="search-button"><a class="site-page social-icon search" href="javascript:void(0);"><i class="fas fa-search fa-fw"></i><span> 搜索</span></a></div><div class="menus_items"><div class="menus_item"><a class="site-page" href="/songkaiixong/songkaixiong.git/"><i class="fa-fw fas fa-home"></i><span> 首页</span></a></div><div class="menus_item"><a class="site-page" href="/songkaiixong/songkaixiong.git/archives/"><i class="fa-fw fas fa-archive"></i><span> 时间轴</span></a></div><div class="menus_item"><a class="site-page" href="/songkaiixong/songkaixiong.git/tags/"><i class="fa-fw fas fa-tags"></i><span> 标签</span></a></div><div class="menus_item"><a class="site-page" href="/songkaiixong/songkaixiong.git/categories/"><i class="fa-fw fas fa-folder-open"></i><span> 分类</span></a></div><div class="menus_item"><a class="site-page" href="/songkaiixong/songkaixiong.git/link/"><i class="fa-fw fas fa-link"></i><span> 友链</span></a></div><div class="menus_item"><a class="site-page" href="/songkaiixong/songkaixiong.git/about/"><i class="fa-fw fas fa-heart"></i><span> 关于</span></a></div></div><div id="toggle-menu"><a class="site-page" href="javascript:void(0);"><i class="fas fa-bars fa-fw"></i></a></div></div></nav><div id="post-info"><h1 class="post-title">Docker安装</h1><div id="post-meta"><div class="meta-firstline"><span class="post-meta-date"><i class="far fa-calendar-alt fa-fw post-meta-icon"></i><span class="post-meta-label">发表于</span><time class="post-meta-date-created" datetime="2023-03-09T13:34:28.018Z" title="发表于 2023-03-09 21:34:28">2023-03-09</time><span class="post-meta-separator">|</span><i class="fas fa-history fa-fw post-meta-icon"></i><span class="post-meta-label">更新于</span><time class="post-meta-date-updated" datetime="2023-03-09T13:35:46.712Z" title="更新于 2023-03-09 21:35:46">2023-03-09</time></span></div><div class="meta-secondline"><span class="post-meta-separator">|</span><span class="post-meta-wordcount"><i class="far fa-file-word fa-fw post-meta-icon"></i><span class="post-meta-label">字数总计:</span><span class="word-count">1.4k</span><span class="post-meta-separator">|</span><i class="far fa-clock fa-fw post-meta-icon"></i><span class="post-meta-label">阅读时长:</span><span>7分钟</span></span><span class="post-meta-separator">|</span><span class="post-meta-pv-cv" id="" data-flag-title="Docker安装"><i class="far fa-eye fa-fw post-meta-icon"></i><span class="post-meta-label">阅读量:</span><span id="busuanzi_value_page_pv"><i class="fa-solid fa-spinner fa-spin"></i></span></span></div></div></div></header><main class="layout" id="content-inner"><div id="post"><article class="post-content" id="article-container"><h1 id="安装containerd"><a href="#安装containerd" class="headerlink" title="安装containerd"></a>安装containerd</h1><h2 id="上传文件后解压缩"><a href="#上传文件后解压缩" class="headerlink" title="上传文件后解压缩"></a>上传文件后解压缩</h2><figure class="highlight plaintext"><table><tr><td class="gutter"><pre><span class="line">1</span><br></pre></td><td class="code"><pre><span class="line">tar -xvf cri-containerd-cni-1.6.4-linux-arm64.tar.gz -C /</span><br></pre></td></tr></table></figure>

<figure class="highlight plaintext"><table><tr><td class="gutter"><pre><span class="line">1</span><br></pre></td><td class="code"><pre><span class="line">mkdir /etc/containerd</span><br></pre></td></tr></table></figure>

<figure class="highlight plaintext"><table><tr><td class="gutter"><pre><span class="line">1</span><br></pre></td><td class="code"><pre><span class="line">containerd config default &gt; /etc/containerd/config.toml</span><br></pre></td></tr></table></figure>

<figure class="highlight plaintext"><table><tr><td class="gutter"><pre><span class="line">1</span><br><span class="line">2</span><br></pre></td><td class="code"><pre><span class="line">systemctl start containerd</span><br><span class="line">systemctl enable containerd</span><br></pre></td></tr></table></figure>

<figure class="highlight plaintext"><table><tr><td class="gutter"><pre><span class="line">1</span><br><span class="line">2</span><br><span class="line">3</span><br><span class="line">4</span><br><span class="line">5</span><br><span class="line">6</span><br><span class="line">7</span><br><span class="line">8</span><br><span class="line">9</span><br><span class="line">10</span><br><span class="line">11</span><br><span class="line">12</span><br></pre></td><td class="code"><pre><span class="line">swapoff -a</span><br><span class="line"></span><br><span class="line">vim /etc/fstab </span><br><span class="line">   </span><br><span class="line">  注释：  #/dev/mapper/openeuler-swap none                    swap    defaults        0 0</span><br><span class="line"></span><br><span class="line">[root@master ~]# systemctl stop firewalld</span><br><span class="line">[root@master ~]# systemctl disable firewalld</span><br><span class="line">[root@master ~]# vim /etc/selinux/config </span><br><span class="line">修改：  SELINUX=disabled</span><br><span class="line"></span><br><span class="line">[root@master ~]# setenforce 0</span><br></pre></td></tr></table></figure>

<h2 id="1、导入离线组件"><a href="#1、导入离线组件" class="headerlink" title="1、导入离线组件"></a>1、导入离线组件</h2><p>组件链接：</p>
<blockquote>
<p><a target="_blank" rel="noopener" href="https://mirrors.aliyun.com/kubernetes/yum/repos/kubernetes-el7-aarch64/Packages/?spm=a2c6h.25603864.0.0.45242678claTZp">kubernetes-yum-repos-kubernetes-el7-aarch64-Packages安装包下载_开源镜像站-阿里云 (aliyun.com)</a></p>
</blockquote>
<p>本机目录：</p>
<blockquote>
<p>D:\wendang\移动\手动部署k8s\离线组件</p>
</blockquote>
<p>如下文件：</p>
<figure class="highlight plaintext"><table><tr><td class="gutter"><pre><span class="line">1</span><br><span class="line">2</span><br><span class="line">3</span><br><span class="line">4</span><br><span class="line">5</span><br></pre></td><td class="code"><pre><span class="line">cri-tools-1.26.0-0.aarch64.rpm  </span><br><span class="line">kubectl-1.26.2-0.aarch64.rpm  </span><br><span class="line">kubernetes-cni-1.2.0-0.aarch64.rpm</span><br><span class="line">kubeadm-1.26.2-0.aarch64.rpm    </span><br><span class="line">kubelet-1.26.2-0.aarch64.rpm</span><br></pre></td></tr></table></figure>

<p>使用以下命令安装组件</p>
<figure class="highlight plaintext"><table><tr><td class="gutter"><pre><span class="line">1</span><br><span class="line">2</span><br><span class="line">3</span><br><span class="line">4</span><br><span class="line">5</span><br></pre></td><td class="code"><pre><span class="line">rpm -ivh cri-tools-1.26.0-0.aarch64.rpm --force --nodeps</span><br><span class="line">rpm -ivh kubectl-1.26.2-0.aarch64.rpm --force --nodeps</span><br><span class="line">rpm -ivh kubernetes-cni-1.2.0-0.aarch64.rpm --force --nodeps</span><br><span class="line">rpm -ivh kubeadm-1.26.2-0.aarch64.rpm --force --nodeps</span><br><span class="line">rpm -ivh kubelet-1.26.2-0.aarch64.rpm --force --nodeps</span><br></pre></td></tr></table></figure>

<p>将kubelet设为开机自启</p>
<figure class="highlight plaintext"><table><tr><td class="gutter"><pre><span class="line">1</span><br></pre></td><td class="code"><pre><span class="line">systemctl enable kubelet</span><br></pre></td></tr></table></figure>

<p>分别在 Master 和 Worker 节点上创建 <code>/etc/sysctl.d/k8s.conf</code> 文件，并添加如下内容。</p>
<figure class="highlight plaintext"><table><tr><td class="gutter"><pre><span class="line">1</span><br><span class="line">2</span><br><span class="line">3</span><br><span class="line">4</span><br></pre></td><td class="code"><pre><span class="line">net.bridge.bridge-nf-call-ip6tables = 1</span><br><span class="line">net.bridge.bridge-nf-call-iptables = 1</span><br><span class="line">net.ipv4.ip_forward = 1</span><br><span class="line">vm.swappiness=0</span><br></pre></td></tr></table></figure>

<p>分别在 Master 和 Worker 节点上执行如下命令，使修改生效。</p>
<figure class="highlight plaintext"><table><tr><td class="gutter"><pre><span class="line">1</span><br><span class="line">2</span><br></pre></td><td class="code"><pre><span class="line">modprobe br_netfilter</span><br><span class="line">sysctl -p /etc/sysctl.d/k8s.conf</span><br></pre></td></tr></table></figure>

<p>修改&#x2F;ets&#x2F;hosts的配置文件</p>
<figure class="highlight plaintext"><table><tr><td class="gutter"><pre><span class="line">1</span><br><span class="line">2</span><br></pre></td><td class="code"><pre><span class="line">[root@master ~]# vim /etc/hosts</span><br><span class="line">添加节点ip、主机名</span><br></pre></td></tr></table></figure>

<h2 id="2、配置镜像"><a href="#2、配置镜像" class="headerlink" title="2、配置镜像"></a>2、配置镜像</h2><p>查看当前k8s版本需要哪些镜像</p>
<figure class="highlight plaintext"><table><tr><td class="gutter"><pre><span class="line">1</span><br></pre></td><td class="code"><pre><span class="line">kubeadm config images list</span><br></pre></td></tr></table></figure>

<p>需要以下镜像</p>
<figure class="highlight plaintext"><table><tr><td class="gutter"><pre><span class="line">1</span><br><span class="line">2</span><br><span class="line">3</span><br><span class="line">4</span><br><span class="line">5</span><br><span class="line">6</span><br><span class="line">7</span><br></pre></td><td class="code"><pre><span class="line">registry.k8s.io/kube-apiserver:v1.26.2</span><br><span class="line">registry.k8s.io/kube-controller-manager:v1.26.2</span><br><span class="line">registry.k8s.io/kube-scheduler:v1.26.2</span><br><span class="line">registry.k8s.io/kube-proxy:v1.26.2</span><br><span class="line">registry.k8s.io/pause:3.9</span><br><span class="line">registry.k8s.io/etcd:3.5.6-0</span><br><span class="line">registry.k8s.io/coredns/coredns:v1.9.3</span><br></pre></td></tr></table></figure>

<p>更改yum源</p>
<figure class="highlight plaintext"><table><tr><td class="gutter"><pre><span class="line">1</span><br><span class="line">2</span><br><span class="line">3</span><br><span class="line">4</span><br><span class="line">5</span><br><span class="line">6</span><br><span class="line">7</span><br><span class="line">8</span><br><span class="line">9</span><br><span class="line">10</span><br><span class="line">11</span><br></pre></td><td class="code"><pre><span class="line">cat &lt;&lt;EOF &gt; /etc/yum.repos.d/kubernetes.repo</span><br><span class="line"></span><br><span class="line">[kubernetes]</span><br><span class="line">name=Kubernetes</span><br><span class="line">baseurl=https://mirrors.aliyun.com/kubernetes/yum/repos/kubernetes-el7-aarch64</span><br><span class="line">enable=1</span><br><span class="line">gpgcheck=1</span><br><span class="line">repo_gpgcheck=1</span><br><span class="line">gpgkey=http://mirrors.aliyun.com/kubernetes/yum/doc/yum-key.gpg</span><br><span class="line">      http://mirrors.aliyun.com/kubernetes/yum/doc/rpm-package-key.gpg</span><br><span class="line">EOF</span><br></pre></td></tr></table></figure>

<p>找一台能上网的arm架构的openeuler系统的服务器执行以下命令下载镜像</p>
<figure class="highlight plaintext"><table><tr><td class="gutter"><pre><span class="line">1</span><br><span class="line">2</span><br><span class="line">3</span><br><span class="line">4</span><br><span class="line">5</span><br><span class="line">6</span><br><span class="line">7</span><br><span class="line">8</span><br></pre></td><td class="code"><pre><span class="line">docker pull registry.cn-hangzhou.aliyuncs.com/google_containers/kube-apiserver:v1.26.2</span><br><span class="line">docker pull registry.cn-hangzhou.aliyuncs.com/google_containers/kube-controller-manager:v1.26.2</span><br><span class="line">docker pull registry.cn-hangzhou.aliyuncs.com/google_containers/kube-scheduler:v1.26.2</span><br><span class="line">docker pull registry.cn-hangzhou.aliyuncs.com/google_containers/kube-proxy:v1.26.2</span><br><span class="line">docker pull registry.cn-hangzhou.aliyuncs.com/google_containers/pause:3.9</span><br><span class="line">docker pull registry.cn-hangzhou.aliyuncs.com/google_containers/etcd:3.5.6-0</span><br><span class="line">docker pull registry.cn-hangzhou.aliyuncs.com/google_containers/coredns:v1.9.3</span><br><span class="line"></span><br></pre></td></tr></table></figure>

<p>将下载的镜像导出</p>
<figure class="highlight plaintext"><table><tr><td class="gutter"><pre><span class="line">1</span><br><span class="line">2</span><br><span class="line">3</span><br><span class="line">4</span><br><span class="line">5</span><br><span class="line">6</span><br><span class="line">7</span><br></pre></td><td class="code"><pre><span class="line">docker save -o kube-apiserver.tar registry.cn-hangzhou.aliyuncs.com/google_containers/kube-apiserver:v1.26.2 </span><br><span class="line">docker save -o kube-controller-manager.tar registry.cn-hangzhou.aliyuncs.com/google_containers/kube-controller-manager:v1.26.2 </span><br><span class="line">docker save -o kube-proxy.tar registry.cn-hangzhou.aliyuncs.com/google_containers/kube-proxy:v1.26.2 </span><br><span class="line">docker save -o kube-scheduler.tar registry.cn-hangzhou.aliyuncs.com/google_containers/kube-scheduler:v1.26.2 </span><br><span class="line">docker save -o etcd.tar registry.cn-hangzhou.aliyuncs.com/google_containers/etcd:3.5.6-0 </span><br><span class="line">docker save -o pause.tar registry.cn-hangzhou.aliyuncs.com/google_containers/pause:3.9 </span><br><span class="line">docker save -o coredns.tar registry.cn-hangzhou.aliyuncs.com/google_containers/coredns:v1.9.3 </span><br></pre></td></tr></table></figure>

<p>再将导出的tar包导入arm服务器，并执行以下命令导入镜像：</p>
<figure class="highlight plaintext"><table><tr><td class="gutter"><pre><span class="line">1</span><br><span class="line">2</span><br><span class="line">3</span><br><span class="line">4</span><br><span class="line">5</span><br><span class="line">6</span><br><span class="line">7</span><br></pre></td><td class="code"><pre><span class="line">ctr -n k8s.io i import coredns.tar --all-platforms</span><br><span class="line">ctr -n k8s.io i import etcd.tar --all-platforms</span><br><span class="line">ctr -n k8s.io i import kube-apiserver.tar --all-platforms</span><br><span class="line">ctr -n k8s.io i import kube-controller-manager.tar --all-platforms</span><br><span class="line">ctr -n k8s.io i import kube-proxy.tar --all-platforms</span><br><span class="line">ctr -n k8s.io i import kube-scheduler.tar --all-platforms</span><br><span class="line">ctr -n k8s.io i import pause.tar --all-platforms</span><br></pre></td></tr></table></figure>

<p>更改&#x2F;etc&#x2F;containerd&#x2F;config.toml配置文件：</p>
<figure class="highlight plaintext"><table><tr><td class="gutter"><pre><span class="line">1</span><br><span class="line">2</span><br><span class="line">3</span><br><span class="line">4</span><br><span class="line">5</span><br><span class="line">6</span><br><span class="line">7</span><br><span class="line">8</span><br></pre></td><td class="code"><pre><span class="line">[root@master manifests]# cat /etc/containerd/config.toml</span><br><span class="line"></span><br><span class="line">                   更改以下：</span><br><span class="line">...                   </span><br><span class="line">         SystemdCgroup = true</span><br><span class="line">...</span><br><span class="line">sandbox_image = &quot;registry.cn-hangzhou.aliyuncs.com/google_containers/pause:3.9&quot;</span><br><span class="line">#注意“registry.aliyuncs.com/google_containers”要改为pull到的镜像仓库前缀！！！</span><br></pre></td></tr></table></figure>

<h2 id="3、初始化k8s"><a href="#3、初始化k8s" class="headerlink" title="3、初始化k8s"></a>3、初始化k8s</h2><figure class="highlight plaintext"><table><tr><td class="gutter"><pre><span class="line">1</span><br></pre></td><td class="code"><pre><span class="line">kubeadm init --apiserver-advertise-address=172.30.201.210  --apiserver-bind-port=6443 --kubernetes-version=v1.26.2 --pod-network-cidr=10.233.0.0/16 --service-cidr=172.30.0.0/16 --image-repository=registry.cn-hangzhou.aliyuncs.com/google_containers --ignore-preflight-errors=swap</span><br></pre></td></tr></table></figure>

<p>遇到报错：</p>
<p><img src="/songkaiixong/songkaixiong.git/img/image-20230307092511060.png" alt="image-20230307092511060"></p>
<p>解决方法：</p>
<p>安装socat，conntrack等依赖包</p>
<p>找一台能联网的arm服务器</p>
<figure class="highlight plaintext"><table><tr><td class="gutter"><pre><span class="line">1</span><br><span class="line">2</span><br><span class="line">3</span><br><span class="line">4</span><br><span class="line">5</span><br><span class="line">6</span><br><span class="line">7</span><br></pre></td><td class="code"><pre><span class="line">mkdir socat</span><br><span class="line">cd socat/</span><br><span class="line">dnf install -y socat --downloadonly --downloaddir=/root/socat</span><br><span class="line"> </span><br><span class="line">mkdir conntrack</span><br><span class="line">cd conntrack/</span><br><span class="line">dnf install -y conntrack --downloadonly --downloaddir=/root/conntrack</span><br></pre></td></tr></table></figure>

<p>然后将socat和conntrack两个文件夹导入到服务器中</p>
<figure class="highlight plaintext"><table><tr><td class="gutter"><pre><span class="line">1</span><br><span class="line">2</span><br><span class="line">3</span><br><span class="line">4</span><br><span class="line">5</span><br></pre></td><td class="code"><pre><span class="line">cd socat/</span><br><span class="line">rpm -ivh socat-1.7.3.2-7.eulerosv2r8.aarch64.rpm --force --nodeps</span><br><span class="line"></span><br><span class="line">cd conntrack/</span><br><span class="line">rpm -ivh *</span><br></pre></td></tr></table></figure>

<p>继续出初始化：</p>
<figure class="highlight plaintext"><table><tr><td class="gutter"><pre><span class="line">1</span><br><span class="line">2</span><br><span class="line">3</span><br></pre></td><td class="code"><pre><span class="line">systemctl restart containerd</span><br><span class="line">systemctl daemon-reload </span><br><span class="line">systemctl restart kubelet.service</span><br></pre></td></tr></table></figure>

<figure class="highlight plaintext"><table><tr><td class="gutter"><pre><span class="line">1</span><br></pre></td><td class="code"><pre><span class="line">kubeadm init --apiserver-advertise-address=172.30.201.210  --apiserver-bind-port=6443 --kubernetes-version=v1.26.2 --pod-network-cidr=10.233.0.0/16 --service-cidr=172.30.0.0/16 --image-repository=registry.cn-hangzhou.aliyuncs.com/google_containers</span><br></pre></td></tr></table></figure>

<p>出现以下字段即为初始化成功：</p>
<p><img src="/songkaiixong/songkaixiong.git/img/image-20230307095840362.png" alt="image-20230307095840362"></p>
<p>按照提示输入以下命令：</p>
<figure class="highlight plaintext"><table><tr><td class="gutter"><pre><span class="line">1</span><br><span class="line">2</span><br><span class="line">3</span><br><span class="line">4</span><br><span class="line">5</span><br><span class="line">6</span><br><span class="line">7</span><br></pre></td><td class="code"><pre><span class="line">mkdir -p $HOME/.kube</span><br><span class="line">sudo cp -i /etc/kubernetes/admin.conf $HOME/.kube/config</span><br><span class="line">sudo chown $(id -u):$(id -g) $HOME/.kube/config</span><br><span class="line"></span><br><span class="line">加入集群使用：</span><br><span class="line">kubeadm join 172.30.201.210:6443 --token wdf28x.2okoq90gzwg72325 \</span><br><span class="line">	--discovery-token-ca-cert-hash sha256:7efe758ad39bb0d746f9986b0bcb508f17db12c9fbedbb3b525e9e0770966865</span><br></pre></td></tr></table></figure>

<p>我们可以看到两个coredns的pod没有正常reday，这是因为缺少网络组件</p>
<p><img src="/songkaiixong/songkaixiong.git/img/image-20230307100041830.png" alt="image-20230307100041830"></p>
<p>去除节点污点：</p>
<figure class="highlight plaintext"><table><tr><td class="gutter"><pre><span class="line">1</span><br><span class="line">2</span><br><span class="line">3</span><br><span class="line">4</span><br><span class="line">5</span><br><span class="line">6</span><br></pre></td><td class="code"><pre><span class="line">[root@master210 ~]# kubectl describe nodes master210 | grep Taint</span><br><span class="line">Taints:             node-role.kubernetes.io/control-plane:NoSchedule</span><br><span class="line">[root@master210 ~]# kubectl taint node master210 node-role.kubernetes.io/control-plane:NoSchedule-</span><br><span class="line">node/master210 untainted</span><br><span class="line">[root@master210 ~]# kubectl describe nodes master210 | grep Taint</span><br><span class="line">Taints:             &lt;none&gt;</span><br></pre></td></tr></table></figure>

<h2 id="将kubectl命令加入tab自动补全"><a href="#将kubectl命令加入tab自动补全" class="headerlink" title="将kubectl命令加入tab自动补全"></a>将kubectl命令加入tab自动补全</h2><figure class="highlight plaintext"><table><tr><td class="gutter"><pre><span class="line">1</span><br><span class="line">2</span><br><span class="line">3</span><br></pre></td><td class="code"><pre><span class="line">[root@master ~]# source  /usr/share/bash-completion/bash_completion </span><br><span class="line">[root@master ~]# source  &lt;(kubectl  completion bash)</span><br><span class="line">[root@master ~]# echo   &quot; source  &lt;(kubectl  completion bash)&quot;  &gt;&gt;  ~/.bashrc</span><br></pre></td></tr></table></figure>

<h2 id="设置tab键的距离"><a href="#设置tab键的距离" class="headerlink" title="设置tab键的距离"></a>设置tab键的距离</h2><figure class="highlight plaintext"><table><tr><td class="gutter"><pre><span class="line">1</span><br><span class="line">2</span><br><span class="line">3</span><br></pre></td><td class="code"><pre><span class="line">[root@master ~]# vim  .vimrc</span><br><span class="line">set tabstop=2</span><br><span class="line">[root@master ~]# source .vimrc</span><br></pre></td></tr></table></figure>

<h2 id="添加calico网络组件："><a href="#添加calico网络组件：" class="headerlink" title="添加calico网络组件："></a>添加calico网络组件：</h2><p>calico官网：</p>
<blockquote>
<p><a target="_blank" rel="noopener" href="https://projectcalico.docs.tigera.io/about/about-calico">https://projectcalico.docs.tigera.io/about/about-calico</a></p>
</blockquote>
<p>默认跳转最新版calico</p>
<p>导入镜像文件：</p>
<blockquote>
<p>calico-apiserver.tar  calico-kube-controllers.tar       calico-typha325.tar    pod2daemon-flexvol.tar<br>calico-cni.tar        calico-node-driver-registrar.tar  calico-csi.tar        calico-node.tar                   operator129.tar</p>
</blockquote>
<figure class="highlight plaintext"><table><tr><td class="gutter"><pre><span class="line">1</span><br><span class="line">2</span><br><span class="line">3</span><br><span class="line">4</span><br><span class="line">5</span><br><span class="line">6</span><br><span class="line">7</span><br><span class="line">8</span><br><span class="line">9</span><br></pre></td><td class="code"><pre><span class="line">ctr -n k8s.io i import calico-apiserver.tar</span><br><span class="line">ctr -n k8s.io i import calico-kube-controllers.tar</span><br><span class="line">ctr -n k8s.io i import calico-typha325.tar</span><br><span class="line">ctr -n k8s.io i import pod2daemon-flexvol.tar</span><br><span class="line">ctr -n k8s.io i import calico-cni.tar</span><br><span class="line">ctr -n k8s.io i import calico-node-driver-registrar.tar</span><br><span class="line">ctr -n k8s.io i import calico-csi.tar</span><br><span class="line">ctr -n k8s.io i import calico-node.tar</span><br><span class="line">ctr -n k8s.io i import operator129.tar</span><br></pre></td></tr></table></figure>

<p>导入yaml文件：</p>
<blockquote>
<p>custom-resources.yaml  tigera-operator.yaml</p>
</blockquote>
<figure class="highlight plaintext"><table><tr><td class="gutter"><pre><span class="line">1</span><br><span class="line">2</span><br></pre></td><td class="code"><pre><span class="line">kubectl create -f tigera-operator.yaml</span><br><span class="line">kubectl create -f custom-resources.yaml</span><br></pre></td></tr></table></figure>

<p>查看创建状态：</p>
<p><img src="/songkaiixong/songkaixiong.git/img/image-20230308122646591.png" alt="image-20230308122646591"></p>
<p><img src="/songkaiixong/songkaixiong.git/img/image-20230308122704844.png" alt="image-20230308122704844"></p>
<p><img src="/songkaiixong/songkaixiong.git/img/image-20230308122722098.png" alt="image-20230308122722098"></p>
</article><div class="post-copyright"><div class="post-copyright__author"><span class="post-copyright-meta">文章作者: </span><span class="post-copyright-info"><a href="https://gitee.com/songkaiixong/songkaixiong.git">凯雄</a></span></div><div class="post-copyright__type"><span class="post-copyright-meta">文章链接: </span><span class="post-copyright-info"><a href="https://gitee.com/songkaiixong/songkaixiong.git/2023/03/09/02%E6%89%8B%E5%8A%A8%E9%83%A8%E7%BD%B2k8s/">https://gitee.com/songkaiixong/songkaixiong.git/2023/03/09/02%E6%89%8B%E5%8A%A8%E9%83%A8%E7%BD%B2k8s/</a></span></div><div class="post-copyright__notice"><span class="post-copyright-meta">版权声明: </span><span class="post-copyright-info">本博客所有文章除特别声明外，均采用 <a href="https://creativecommons.org/licenses/by-nc-sa/4.0/" target="_blank">CC BY-NC-SA 4.0</a> 许可协议。转载请注明来自 <a href="https://gitee.com/songkaiixong/songkaixiong.git" target="_blank">卖萌的西瓜拐了夏天当媳妇</a>！</span></div></div><div class="tag_share"><div class="post-meta__tag-list"></div><div class="post_share"><div class="social-share" data-image="/songkaiixong/songkaixiong.git/img/docker%E5%AE%89%E8%A3%85%E6%AD%A5%E9%AA%A4.jpg" data-sites="facebook,twitter,wechat,weibo,qq"></div><link rel="stylesheet" href="https://cdn.jsdelivr.net/npm/butterfly-extsrc/sharejs/dist/css/share.min.css" media="print" onload="this.media='all'"><script src="https://cdn.jsdelivr.net/npm/butterfly-extsrc/sharejs/dist/js/social-share.min.js" defer></script></div></div></div><div class="aside-content" id="aside-content"><div class="card-widget card-info"><div class="is-center"><div class="avatar-img"><img src="/songkaiixong/songkaixiong.git/img/touxiang.png" onerror="this.onerror=null;this.src='/songkaiixong/songkaixiong.git/img/friend_404.gif'" alt="avatar"/></div><div class="author-info__name">凯雄</div><div class="author-info__description">淡淡酒香、诗雨伊意、九八野马、九点钟的你</div></div><div class="card-info-data site-data is-center"><a href="/songkaiixong/songkaixiong.git/archives/"><div class="headline">文章</div><div class="length-num">2</div></a><a href="/songkaiixong/songkaixiong.git/tags/"><div class="headline">标签</div><div class="length-num">0</div></a><a href="/songkaiixong/songkaixiong.git/categories/"><div class="headline">分类</div><div class="length-num">0</div></a></div><a id="card-info-btn" target="_blank" rel="noopener" href="https://github.com/xxxxxx"><i class="fab fa-github"></i><span>🛴前往小家...</span></a></div><div class="card-widget card-announcement"><div class="item-headline"><i class="fas fa-bullhorn fa-shake"></i><span>公告</span></div><div class="announcement_content">当地比较有名的土豆杀手</div></div><div class="sticky_layout"><div class="card-widget" id="card-toc"><div class="item-headline"><i class="fas fa-stream"></i><span>目录</span><span class="toc-percentage"></span></div><div class="toc-content"><ol class="toc"><li class="toc-item toc-level-1"><a class="toc-link" href="#%E5%AE%89%E8%A3%85containerd"><span class="toc-number">1.</span> <span class="toc-text">安装containerd</span></a><ol class="toc-child"><li class="toc-item toc-level-2"><a class="toc-link" href="#%E4%B8%8A%E4%BC%A0%E6%96%87%E4%BB%B6%E5%90%8E%E8%A7%A3%E5%8E%8B%E7%BC%A9"><span class="toc-number">1.1.</span> <span class="toc-text">上传文件后解压缩</span></a></li><li class="toc-item toc-level-2"><a class="toc-link" href="#1%E3%80%81%E5%AF%BC%E5%85%A5%E7%A6%BB%E7%BA%BF%E7%BB%84%E4%BB%B6"><span class="toc-number">1.2.</span> <span class="toc-text">1、导入离线组件</span></a></li><li class="toc-item toc-level-2"><a class="toc-link" href="#2%E3%80%81%E9%85%8D%E7%BD%AE%E9%95%9C%E5%83%8F"><span class="toc-number">1.3.</span> <span class="toc-text">2、配置镜像</span></a></li><li class="toc-item toc-level-2"><a class="toc-link" href="#3%E3%80%81%E5%88%9D%E5%A7%8B%E5%8C%96k8s"><span class="toc-number">1.4.</span> <span class="toc-text">3、初始化k8s</span></a></li><li class="toc-item toc-level-2"><a class="toc-link" href="#%E5%B0%86kubectl%E5%91%BD%E4%BB%A4%E5%8A%A0%E5%85%A5tab%E8%87%AA%E5%8A%A8%E8%A1%A5%E5%85%A8"><span class="toc-number">1.5.</span> <span class="toc-text">将kubectl命令加入tab自动补全</span></a></li><li class="toc-item toc-level-2"><a class="toc-link" href="#%E8%AE%BE%E7%BD%AEtab%E9%94%AE%E7%9A%84%E8%B7%9D%E7%A6%BB"><span class="toc-number">1.6.</span> <span class="toc-text">设置tab键的距离</span></a></li><li class="toc-item toc-level-2"><a class="toc-link" href="#%E6%B7%BB%E5%8A%A0calico%E7%BD%91%E7%BB%9C%E7%BB%84%E4%BB%B6%EF%BC%9A"><span class="toc-number">1.7.</span> <span class="toc-text">添加calico网络组件：</span></a></li></ol></li></ol></div></div></div></div></main><footer id="footer"><div id="footer-wrap"><div class="copyright">&copy;2020 - 2023 By 凯雄</div><div class="footer_custom_text">淡淡酒香、诗雨伊意、九八野马、九点钟的你</div></div></footer></div><div id="rightside"><div id="rightside-config-hide"><button id="readmode" type="button" title="阅读模式"><i class="fas fa-book-open"></i></button><button id="hide-aside-btn" type="button" title="单栏和双栏切换"><i class="fas fa-arrows-alt-h"></i></button></div><div id="rightside-config-show"><button id="rightside_config" type="button" title="设置"><i class="fas fa-cog fa-spin"></i></button><button class="close" id="mobile-toc-button" type="button" title="目录"><i class="fas fa-list-ul"></i></button><button id="go-up" type="button" title="回到顶部"><span class="scroll-percent"></span><i class="fas fa-arrow-up"></i></button></div><span id="percent">0<span>%</span></span></div><div><script src="/songkaiixong/songkaixiong.git/js/utils.js"></script><script src="/songkaiixong/songkaixiong.git/js/main.js"></script><script src="https://cdn.jsdelivr.net/npm/@fancyapps/ui/dist/fancybox.umd.min.js"></script><div class="js-pjax"></div><script defer src="/js/cursor.js"></script><script defer data-pjax src="/js/readPercent.js"></script><script src="/js/sun_moon.js" async></script><canvas id="universe"></canvas><script defer src="/js/universe.js"></script><script async src="/js/title.js"></script><script async data-pjax src="//busuanzi.ibruce.info/busuanzi/2.3/busuanzi.pure.mini.js"></script></div><div id="local-search"><div class="search-dialog"><nav class="search-nav"><span class="search-dialog-title">搜索</span><span id="loading-status"></span><button class="search-close-button"><i class="fas fa-times"></i></button></nav><div class="is-center" id="loading-database"><i class="fas fa-spinner fa-pulse"></i><span>  数据库加载中</span></div><div class="search-wrap"><div id="local-search-input"><div class="local-search-box"><input class="local-search-box--input" placeholder="搜索文章" type="text"/></div></div><hr/><div id="local-search-results"></div></div></div><div id="search-mask"></div><script src="/songkaiixong/songkaixiong.git/js/search/local-search.js"></script></div><!-- hexo injector body_end start --><div class="js-pjax"><script async="async">var arr = document.getElementsByClassName('recent-post-item');
for(var i = 0;i<arr.length;i++){
    arr[i].classList.add('wow');
    arr[i].classList.add('animate__zoomIn');
    arr[i].setAttribute('data-wow-duration', '2s');
    arr[i].setAttribute('data-wow-delay', '1s');
    arr[i].setAttribute('data-wow-offset', '100');
    arr[i].setAttribute('data-wow-iteration', '2');
  }</script><script async="async">var arr = document.getElementsByClassName('card-widget');
for(var i = 0;i<arr.length;i++){
    arr[i].classList.add('wow');
    arr[i].classList.add('animate__zoomIn');
    arr[i].setAttribute('data-wow-duration', '');
    arr[i].setAttribute('data-wow-delay', '');
    arr[i].setAttribute('data-wow-offset', '');
    arr[i].setAttribute('data-wow-iteration', '');
  }</script></div><script defer src="https://npm.elemecdn.com/hexo-butterfly-wowjs/lib/wow.min.js"></script><script defer src="https://npm.elemecdn.com/hexo-butterfly-wowjs/lib/wow_init.js"></script><script data-pjax src="https://npm.elemecdn.com/hexo-filter-gitcalendar/lib/gitcalendar.js"></script><script data-pjax>
  function gitcalendar_injector_config(){
      var parent_div_git = document.getElementById('recent-posts');
      var item_html = '<div class="recent-post-item" id="gitcalendarBar" style="width:100%;height:auto;padding:10px;"><style>#git_container{min-height: 280px}@media screen and (max-width:650px) {#git_container{min-height: 0px}}</style><div id="git_loading" style="width:10%;height:100%;margin:0 auto;display: block;"><svg xmlns="http://www.w3.org/2000/svg" xmlns:xlink="http://www.w3.org/1999/xlink" viewBox="0 0 50 50" style="enable-background:new 0 0 50 50" xml:space="preserve"><path fill="#d0d0d0" d="M25.251,6.461c-10.318,0-18.683,8.365-18.683,18.683h4.068c0-8.071,6.543-14.615,14.615-14.615V6.461z" transform="rotate(275.098 25 25)"><animatetransform attributeType="xml" attributeName="transform" type="rotate" from="0 25 25" to="360 25 25" dur="0.6s" repeatCount="indefinite"></animatetransform></path></svg><style>#git_container{display: none;}</style></div><div id="git_container"></div></div>';
      parent_div_git.insertAdjacentHTML("afterbegin",item_html)
      console.log('已挂载gitcalendar')
      }

    if( document.getElementById('recent-posts') && (location.pathname ==='/'|| '/' ==='all')){
        gitcalendar_injector_config()
        GitCalendarInit("https://gitee.com/songkaiixong/songkaixiong.git/api?宋凯雄",['#d9e0df', '#c6e0dc', '#a8dcd4', '#9adcd2', '#89ded1', '#77e0d0', '#5fdecb', '#47dcc6', '#39dcc3', '#1fdabe', '#00dab9'],'宋凯雄')
    }
  </script><!-- hexo injector body_end end --></body></html>